package com.ruoyi.web.core.config;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * admin config
 *
 * @author xuxueli 2017-04-28
 */

@Component
public class AdminConfig implements InitializingBean, DisposableBean {

    private static AdminConfig adminConfig = null;

    public static AdminConfig getAdminConfig() {
        return adminConfig;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        adminConfig = this;
    }

	@Override
	public void destroy() throws Exception {

	}

	/**
	 * 是否生产环境
	 */
	@Value("${ruoyi.env.prod}")
	private boolean isProd;

	/**
	 * 发件人
	 */
	@Value("${spring.mail.username}")
	private String emailUserName;

	/**
	 * 发件人邮箱
	 */
	@Value("${spring.mail.from}")
    private String emailFrom;

	/**
	 * 短信accessKeyId
	 */
	@Value("${aliyun.sms.akid}")
	private String accessKeyId;

	/**
	 * 短信accessKeySecret
	 */
	@Value("${aliyun.sms.aksrt}")
	private String accessKeySecret;

    @Resource
    private JavaMailSender mailSender;


	public String getEmailFrom() {
		return emailFrom;
	}

	public String getEmailUserName() {
		return emailUserName;
	}

	public boolean isProd() {
		return isProd;
	}

	public String getAccessKeyId() {
		return accessKeyId;
	}

	public String getAccessKeySecret() {
		return accessKeySecret;
	}

    public JavaMailSender getMailSender() {
        return mailSender;
    }

}
